package com.icehelper.hades.base.util.httpfluent.constant;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.apache.http.HttpVersion;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicHttpResponse;

/**
 * httpclient 常量
 */
public final class Constant {

  private Constant() {
  }

  public static final String CONFIG_PREFIX = "http-client";

  public static final String HEADER_CONTENT_TYPE = "Content-Type";

  public static final String MIME_WILDCARD = "*/*";

  public static final String MIME_URL_ENCODED = "application/x-www-form-urlencoded";

  public static final String MIME_APPLICATION_JSON = "application/json";

  public static final String MIME_APPLICATION_XML = "application/xml";

  public static final String MIME_TEXT_HTML = "text/html";

  public static final String MIME_TEXT_PLAIN = "text/plain";

  public static final String MIME_MULTIPART_FORM_DATA = "multipart/form-data";

  public static final String MIME_APPLICATION_OCTET_STREAM = "application/octet-stream";

  public static final ContentType APPLICATION_OCTET_STREAM = ContentType.create(MIME_APPLICATION_OCTET_STREAM);

  public static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8;

  public static final ContentType DEFAULT_CONTENT_TYPE = ContentType.create(MIME_URL_ENCODED, Constant.CHARSET_UTF8);

  public static final ContentType APPLICATION_JSON = ContentType.create(MIME_APPLICATION_JSON, Constant.CHARSET_UTF8);

  public static final ContentType TEXT_HTML = ContentType.create(MIME_TEXT_HTML, Constant.CHARSET_UTF8);

  public static final ContentType TEXT_PLAIN = ContentType.create(MIME_TEXT_PLAIN, Constant.CHARSET_UTF8);

  public static final ContentType APPLICATION_XML = ContentType.create(MIME_APPLICATION_XML, Constant.CHARSET_UTF8);

  public static final Integer MAX_LENGTH = 2000 * 1024;

  public static final String FORBIDDEN_BODY = "body内容为二进制或者内容大于" + MAX_LENGTH / 1024 + "k";

  public static final String ERROR_BODY = "读取body内容遇到异常";

  public static final String EMPTY_REQUEST = "请求内容为空";

  public static final String URL_BLANK = "url is blank";

  public static final BasicHttpResponse TIMEOUT_RESPONSE = new BasicHttpResponse(HttpVersion.HTTP_1_1, 504, "请求超时");
}
